<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="__STATIC__/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="__STATIC__/css/font.css">
    <link rel="stylesheet" href="__STATIC__/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="__STATIC__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/js/xadmin.js"></script>
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=QOZWOd8ibC5ycpFhge8oVux01j6KbmAE"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>

    <![endif]-->
</head>

<body>

<div class="x-body">
    <div class="layui-row">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">顾客</li>
                <li>服务员</li>
                <li>厨师</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-col-md4">
                        <form class="layui-form" id="form1">
                            <div class="layui-form-item">
                                <label for="ratio_A" class="layui-form-label">
                                    <span class="x-red">*</span>一级比例
                                </label>
                                <div class="layui-input-inline">
                                    <input type="text" id="ratio_A" name="ratio_A" required="" lay-verify="required"
                                           autocomplete="off" class="layui-input" value="{$data.ratio.ratio_A}">
                                    <input type="hidden" name="id" value="{$data.ratio.id}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="ratio_B" class="layui-form-label">
                                    <span class="x-red">*</span>二级比例
                                </label>
                                <div class="layui-input-inline">
                                    <input type="text" id="ratio_B" name="ratio_B" required="" lay-verify="required"
                                           autocomplete="off" class="layui-input" value="{$data.ratio.ratio_B}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                </label>
                                <button class="layui-btn" lay-filter="add1" lay-submit="">
                                    保存
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-col-md4">
                        <form class="layui-form" id="form2">
                            <div class="layui-form-item">
                                <label for="ratio_A" class="layui-form-label">
                                    <span class="x-red">*</span>分销类型
                                </label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="status" value="1" title="订单"
                                           {$data.waiter.status==1?"checked":""}>
                                    <input type="radio" name="status" value="2" title="人数"
                                           {$data.waiter.status==2?"checked":""}>
                                    <input type="hidden" name="id" value="">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>分销比例
                                </label>
                                <div class="layui-input-inline">
                                    <input type="text" id="" name="ratio" required="" lay-verify="required"
                                           autocomplete="off" class="layui-input"
                                           value="{$data.waiter.status==1?$data.waiter.value:$data.waiter.money}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">
                                    <span class="x-red">*</span>类型为订单时为百分比，为人数时为金额。ps:请输入整数
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                </label>
                                <button class="layui-btn" lay-filter="add2" lay-submit="">
                                    保存
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-col-md4">
                        <form class="layui-form" id="form3">
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    <span class="x-red">*</span>制作比例
                                </label>
                                <div class="layui-input-inline">
                                    <input type="text" name="make" required="" lay-verify="required"
                                           autocomplete="off" class="layui-input" value="{$data.cook.make}">
                                    <input type="hidden" name="id" value="{$data.cook.id}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label for="ratio_B" class="layui-form-label">
                                    <span class="x-red">*</span>发明比例
                                </label>
                                <div class="layui-input-inline">
                                    <input type="text" name="invent" required="" lay-verify="required"
                                           autocomplete="off" class="layui-input" value="{$data.cook.invent}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                </label>
                                <button class="layui-btn" lay-filter="add3" lay-submit="">
                                    保存
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">

    layui.use(['form', 'layer', 'upload', 'laydate'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        //监听提交
        form.on('submit(add1)', function (data) {
            console.log(data.field);
            $.post('{:url("shop/save")}', data.field, function (res) {
                if (res.code == 2 && res.code == 0) {
                    layer.msg(res.msg, {icon: 5});
                } else {
                    layer.alert(res.msg, {icon: 6}, function () {
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }
            });
            return false;
        });
        form.on('submit(add2)', function (data) {
            console.log(data.field);
            $.post('{:url("shop/save")}', data.field, function (res) {
                if (res.code == 2 && res.code == 0) {
                    layer.msg(res.msg, {icon: 5});
                } else {
                    layer.alert(res.msg, {icon: 6}, function () {
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }
            });
            return false;
        });
        form.on('submit(add3)', function (data) {
            $.post('{:url("shop/save")}', data.field, function (res) {
                console.log(res);
                if (res.code == 2 && res.code == 0) {
                    layer.msg(res.msg, {icon: 5});
                } else {
                    layer.alert(res.msg, {icon: 6}, function () {
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }
            });
            return false;
        });

    });
</script>
</body>

</html>